
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Zuul和Gateway区别 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Zuul和Gateway区别 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Netflix Zuul是基于哪种编程模型构建的？这种模型在高并发场景下可能存在什么问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zuul是基于Servlet编程模型构建的，依赖于Servlet容器来处理HTTP请求。这种模型是基于阻塞I/O的，因此在高并发场景下，其性能和扩展性可能存在瓶颈。</div>
          </div>
          <div class="card-source">来源: Netflix Zuul -> 编程模型 & Zuul的优缺点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Zuul的核心机制是什么？它包含哪四种按执行阶段划分的过滤器类型？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zuul的核心是基于过滤器机制。过滤器按类型分为四类：1. Pre Filters (前置过滤器)：在请求路由之前执行。2. Routing Filters (路由过滤器)：负责将请求路由到服务实例。3. Post Filters (后置过滤器)：在请求被路由之后执行。4. Error Filters (错误过滤器)：在处理请求过程中发生错误时执行。</div>
          </div>
          <div class="card-source">来源: Netflix Zuul -> 编程模型</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Zuul通常与哪个Netflix组件集成以实现客户端负载均衡？负载均衡的实现原理是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zuul通常与Netflix的Ribbon集成以实现客户端负载均衡。其原理是：首先通过服务发现机制（如Eureka）获取服务实例列表，然后根据负载均衡策略选择一个合适的服务实例，最后将请求转发到选定的服务实例。</div>
          </div>
          <div class="card-source">来源: Netflix Zuul -> 路由和负载均衡 -> 负载均衡的实现原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Spring Cloud Gateway基于什么技术栈和编程模型？这为其带来了什么核心优势？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Cloud Gateway基于Spring Framework 5、Spring Boot 2和Project Reactor，采用响应式编程模型，并使用Spring WebFlux框架。其核心优势是支持异步和非阻塞IO，能够以少量线程处理大量并发请求，从而实现更高的处理性能和吞吐量。</div>
          </div>
          <div class="card-source">来源: Spring Cloud Gateway -> 介绍 & 响应式编程模型 & Spring Cloud Gateway的优缺点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring Cloud Gateway的工作原理中，路由断言（Predicate）的作用是什么？请列举至少三种可用的断言条件。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Spring Cloud Gateway中，路由断言用于匹配传入的HTTP请求，以确定是否应将请求路由到目标URI。可用的断言条件包括：Path断言（基于请求路径）、Method断言（基于HTTP方法）、Header断言（基于请求头信息）和Query参数断言（基于请求的查询参数）。</div>
          </div>
          <div class="card-source">来源: Spring Cloud Gateway -> 路由与负载均衡 -> 路由</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">对比</div>
          <div class="card-question">相较于Zuul，Spring Cloud Gateway在性能方面的主要优点是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">对比</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Cloud Gateway的性能优于Zuul。它基于支持异步和非阻塞的响应式编程模型（Project Reactor和Spring WebFlux），而Zuul 1.x基于阻塞I/O，因此Gateway在处理大量并发请求时性能更高，吞吐量也更大。</div>
          </div>
          <div class="card-source">来源: Zuul与Gateway的优缺点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Zuul提供了哪些安全性机制来保护系统？请列举至少四种。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zuul提供了多种安全性机制，包括：1. IP黑白名单；2. 安全头信息过滤；3. SSL终端保护；4. 请求认证和授权（集成OAuth/SSO）；5. API密钥管理；6. 请求限流。</div>
          </div>
          <div class="card-source">来源: Netflix Zuul -> 安全性机制</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">请描述Zuul中过滤器的标准执行顺序。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Zuul的过滤器按照预定的顺序执行。首先执行Pre Filters（前置过滤器），接着执行Routing Filters（路由过滤器）将请求转发出去，然后执行Post Filters（后置过滤器）处理响应。如果在任何阶段发生错误，则会执行Error Filters（错误过滤器）。</div>
          </div>
          <div class="card-source">来源: Netflix Zuul -> 过滤器 -> 过滤器执行顺序</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Spring Cloud Gateway集成了哪个组件来实现负载均衡，并支持哪些负载均衡算法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Cloud Gateway集成了Spring Cloud LoadBalancer来实现负载均衡。它支持的负载均衡算法包括：Round Robin（轮询）、Weighted Response Time（加权响应时间）和Retry（重试）。</div>
          </div>
          <div class="card-source">来源: Spring Cloud Gateway -> 路由与负载均衡 -> 负载均衡</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
